<template>
  <div class="login-container">
    <img src="../../assets/images/logos/logo.png" alt="Logo" class="logo" />
    <div class="login-form">
      <h2>登录</h2>
      <el-form :model="loginForm" label-width="80px">
        <el-form-item label="用户名">
          <el-input v-model="loginForm.username"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input type="password" v-model="loginForm.password" show-password></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"  @click="handleLogin">登录</el-button>

        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import router from "@/router";
import {ElMessage} from "element-plus";


const loginForm = ref({
  username: '',
  password: ''
});

const handleLogin = () => {
  // 处理登录逻辑
  console.log('用户名:', loginForm.value.username);
  console.log('密码:', loginForm.value.password);
  ElMessage.success('登录成功');
  router.push('/');
};
</script>

<style scoped>
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background-color: #6c757d; /* 浅灰色背景 */
  padding: 20px;
}

.logo {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 100px;
  height: auto;
}

.login-form {
  background-color: #ffffff;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  width: 400px;
  text-align: center;
}

.login-form h2 {
  margin-bottom: 20px;
  font-size: 24px;
  color: #333333;
}

.el-form-item {
  text-align: left;
}

.el-button {
  width: 100%;
  margin-top: 20px;
}
</style>
